﻿package view.mornExtends
{
    import __AS3__.vec.*;
    import flash.display.*;
    import morn.core.components.*;

    public class NumberComponent extends Component
    {
        private var mNumber:int = 0;
        private var mIsPercent:Boolean = false;
        private var mSkin:String = "";
        private var mNumList:Vector.<Bitmap>;

        public function NumberComponent(param1:String = "png.common.")
        {
            this.mNumList = new Vector.<Bitmap>;
            this.mSkin = param1;
            return;
        }// end function

        private function updateNumber() : void
        {
            var _loc_5:BitmapData = null;
            var _loc_6:Bitmap = null;
            var _loc_7:Bitmap = null;
            while (this.mNumList.length > 0)
            {
                
                _loc_7 = this.mNumList.shift();
                if (_loc_7.parent)
                {
                    _loc_7.parent.removeChild(_loc_7);
                }
                _loc_7 = null;
            }
            var _loc_1:* = String(this.mNumber);
            var _loc_2:int = 0;
            var _loc_3:* = _loc_1.length;
            var _loc_4:int = 0;
            _loc_2 = 0;
            while (_loc_2 < _loc_3)
            {
                
                _loc_5 = App.asset.getAsset(this.mSkin + _loc_1.charAt(_loc_2));
                _loc_6 = new Bitmap(_loc_5);
                _loc_6.x = _loc_4;
                addChild(_loc_6);
                this.mNumList.push(_loc_6);
                _loc_4 = _loc_4 + _loc_6.width;
                _loc_2++;
            }
            if (this.mIsPercent)
            {
                _loc_5 = App.asset.getAsset(this.mSkin + "pow2_percent");
                _loc_6 = new Bitmap(_loc_5);
                _loc_6.x = _loc_4;
                addChild(_loc_6);
                this.mNumList.push(_loc_6);
            }
            return;
        }// end function

        public function set number(param1:int) : void
        {
            if (param1 == this.mNumber && this.mNumber != 0)
            {
                return;
            }
            this.mNumber = param1;
            this.updateNumber();
            return;
        }// end function

        public function get number() : int
        {
            return this.mNumber;
        }// end function

        public function set isPercent(param1:Boolean) : void
        {
            if (this.mIsPercent == param1)
            {
                return;
            }
            this.mIsPercent = param1;
            this.updateNumber();
            return;
        }// end function

    }
}
